<template>
	<view>
		<view class="w-full text-center">
			<text class="">我的</text>
		</view>
		<view class="p-3">
			<view class="h-[100px] flex flex-row p-3 bg-[#ff5454] rounded-[6px]" v-if="currentUser">
				<view>
					<uv-image :src="currentUser.avatar" height="64px" width="64px"></uv-image>
				</view>
				<view class="h-full flex-grow flex flex-col pl-2 justify-start">
					<view>{{ currentUser.nickname }}</view>
					<view>{{ currentUser.description }}</view>
				</view>
			</view>
			<view>
				<uv-list>
					<uv-list-item title="账号管理" link @click="goToProfile">
					</uv-list-item>
				</uv-list>
			</view>
		</view>
	</view>
</template>

<script setup>
import { onBeforeUnmount, onMounted, reactive, ref, getCurrentInstance } from 'vue';
import authService from "@/services/auth.service";
import personalCenterService from "@/services/personal-center.service";
import { UNI_STORAGE_KEY_USER_PROFILE } from "../../utils/constants";
import { onShow } from "@dcloudio/uni-app";

const currentUser = ref();

const load = async () => {
	const userProfile = uni.getStorageSync(UNI_STORAGE_KEY_USER_PROFILE);
	if (!userProfile) {
		uni.navigateTo({
			url: '/pages/login/login',
		});
		return;
	}
	currentUser.value = userProfile.user;
}

onShow(async () => {
	console.log("mine onShow");
	load();
});

const goToProfile = () => {
	uni.navigateTo({
		url: "/pages/personal-center/profile/profile"
	});
}
</script>

<style lang="scss"></style>